﻿using System;
using System.Collections.Generic;
using System.Data;

namespace DBF_ReadWrite
{
    class DBF_Struct
    {
        public string pFileName;
        public DBF_Header pHeader;
        public List<DBF_Field_description> pField_description = new List<DBF_Field_description> ();
        //public DBF_Field_description[] pField_description;
        public DataTable pDataTable;

        public DBF_Struct(string pDBF_FileName, DBF_Header pDBF_Header, List<DBF_Field_description> pDBF_Field_description, DataTable pDBF_DataTable)
        {
            pFileName = pDBF_FileName;
            pHeader = pDBF_Header;
            pField_description = pDBF_Field_description;
            pDataTable = pDBF_DataTable;
        }

        public DBF_Struct()
        {

        }

        public class DBF_Header
        {
            public char version;  // 1byte
            public char year;  // 1byte
            public char month;  // 1byte
            public char day;  // 1byte
            public Int32 recordn;  // 4byte
            public Int16 header_length;  // 2byte
            public Int16 record_length;  // 2byte
            public char[] ver10_reserved = new char[20];
        }

        public class DBF_Field_description
        {
            public string name;  // 11byte
            public char type;  // 1byte
            public Int32 field_data_adress;  // 4byte
            public byte field_length;  // 1byte
            public char decimal_count;  // 1byte
            public char[] ver10_reserved = new char[14];  // 14byte

            public DBF_Field_description(string pName, char pType, byte pField_length, char pDecimal_count, char[] pVer10_reserved)
            {
                name = pName;
                type = pType;
                field_length = pField_length;
                decimal_count = pDecimal_count;
                ver10_reserved = pVer10_reserved;
            }

            public DBF_Field_description()
            {
            }
        }
    }
}
